package cn.iocoder.yudao.module.wine.dal.mysql.supplylabel;

import java.util.*;
import java.util.stream.Collectors;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.wine.controller.app.supplyinfo.enums.SupplyLabelEnum;
import cn.iocoder.yudao.module.wine.dal.dataobject.supplylabel.SupplyLabelDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.wine.controller.admin.supplylabel.vo.*;

/**
 * 供求标签管理 Mapper
 *
 * @author 管理员
 */
@Mapper
public interface SupplyLabelMapper extends BaseMapperX<SupplyLabelDO> {

    default PageResult<SupplyLabelDO> selectPage(SupplyLabelPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<SupplyLabelDO>()
                .likeIfPresent(SupplyLabelDO::getLabelName, reqVO.getLabelName())
                .betweenIfPresent(SupplyLabelDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(SupplyLabelDO::getId));
    }

    default List<SupplyLabelDO> selectByNameList(List<String> list){
        List<SupplyLabelDO> supplyLabelDOS = selectList(new LambdaQueryWrapperX<SupplyLabelDO>()
                .in(SupplyLabelDO::getLabelName, list));
        return supplyLabelDOS.stream().filter(item -> SupplyLabelEnum.GUARANTEE.getCode().equals(item.getFunctionType())).collect(Collectors.toList());
    }

    default List<SupplyLabelDO> selectByNameListResponsibility(List<String> list){
        List<SupplyLabelDO> supplyLabelDOS = selectList(new LambdaQueryWrapperX<SupplyLabelDO>()
                .in(SupplyLabelDO::getLabelName, list));
        return supplyLabelDOS.stream().filter(item -> SupplyLabelEnum.TAKE_RESPONSIBILITY.getCode().equals(item.getFunctionType())).collect(Collectors.toList());
    }

}
